

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The finalFunctionsMeta module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../index.html" />
    <link rel="up" title="The interfaces module" href="mod_pyamp_patterns_interfaces.html" />
    <link rel="next" title="The requiredProperties module" href="pyamp_patterns_interfaces_requiredProperties.html" />
    <link rel="prev" title="The interfaces module" href="mod_pyamp_patterns_interfaces.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_patterns_interfaces_requiredProperties.html" title="The requiredProperties module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mod_pyamp_patterns_interfaces.html" title="The interfaces module"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_patterns.html" >The patterns module</a> &raquo;</li>
          <li><a href="mod_pyamp_patterns_interfaces.html" accesskey="U">The interfaces module</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.patterns.interfaces.finalFunctionsMeta">
<span id="the-finalfunctionsmeta-module"></span><h1>The finalFunctionsMeta module<a class="headerlink" href="#module-pyamp.patterns.interfaces.finalFunctionsMeta" title="Permalink to this headline">¶</a></h1>
<p>The finalFunctionsMeta module contians classes which provide the
ability to declare specific functions of a class to be &#8216;final&#8217;, which
means that an Exception will be raised in the event that a subclass
tries to override the functionality of those functions.</p>
<p>Here is an example of using the classes in this module:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># First define the metaclass that defines the list of final functions</span>
<span class="k">class</span> <span class="nc">FinalMeta</span><span class="p">(</span><span class="n">FinalFunctionsMeta</span><span class="p">):</span>
    <span class="n">finalFunctions</span> <span class="o">=</span> <span class="p">[</span><span class="s">&quot;__del__&quot;</span><span class="p">]</span>

<span class="c"># Now define the base class which forces all child classes to use the</span>
<span class="c"># correct metaclass</span>
<span class="k">class</span> <span class="nc">Parent</span><span class="p">(</span><span class="n">FinalFunctionsParentBase</span><span class="p">):</span>
    <span class="n">requiredMetaclass</span> <span class="o">=</span> <span class="n">FinalMeta</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">FinalFunctionsParentBase</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

<span class="c"># Finally, define the child class and override a few of the</span>
<span class="c"># parents functions</span>
<span class="k">class</span> <span class="nc">Child</span><span class="p">(</span><span class="n">Parent</span><span class="p">):</span>
    <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">FinalMeta</span>

    <span class="c"># This function can be overridden</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">Parent</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

    <span class="c"># This function CANNOT be overridden</span>
    <span class="k">def</span> <span class="nf">__del__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">Parent</span><span class="o">.</span><span class="n">__del__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

<span class="c"># This will throw an Exception indicating that __del__ cannot be</span>
<span class="c"># overridden by the Child class!</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">Child</span><span class="p">()</span>
</pre></div>
</div>
<div class="section" id="the-requiredproperties-class">
<h2>The RequiredProperties class<a class="headerlink" href="#the-requiredproperties-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-d36b691e0ec3c28d88f0023442a5266604d871c7.png" alt="Inheritance diagram of pyamp.patterns.interfaces.finalFunctionsMeta.RequiredProperties" usemap="#inheritance544d45c886" class="inheritance"/>
<map id="inheritance544d45c886" name="inheritance544d45c886">
<area shape="rect" href="pyamp_patterns_interfaces_requiredProperties.html#pyamp.patterns.interfaces.requiredProperties.RequiredProperties" title="pyamp.patterns.interfaces.requiredProperties.RequiredProperties" alt="" coords="5,7,440,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.patterns.interfaces.finalFunctionsMeta.RequiredProperties">
<em class="property">class </em><tt class="descclassname">pyamp.patterns.interfaces.finalFunctionsMeta.</tt><tt class="descname">RequiredProperties</tt><a class="headerlink" href="#pyamp.patterns.interfaces.finalFunctionsMeta.RequiredProperties" title="Permalink to this definition">¶</a></dt>
<dd><p>The RequiredProperties class provides an interface which allows
subclasses to define a set of properties that must be defined for
that class.</p>
<p>This class checks that all of those properties are defined, and if
one of them is not defined this class throws an exception.</p>
<p>Check that all the required properties are defined.</p>
<dl class="classmethod">
<dt id="pyamp.patterns.interfaces.finalFunctionsMeta.RequiredProperties.checkRequiredProperties">
<em class="property">classmethod </em><tt class="descname">checkRequiredProperties</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#pyamp.patterns.interfaces.finalFunctionsMeta.RequiredProperties.checkRequiredProperties" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="the-finalfunctionsparentbase-class">
<h2>The FinalFunctionsParentBase class<a class="headerlink" href="#the-finalfunctionsparentbase-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-c7b7e86bd170c1465bf56611bae1d0257a534c16.png" alt="Inheritance diagram of pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsParentBase" usemap="#inheritance122ab4aaad" class="inheritance"/>
<map id="inheritance122ab4aaad" name="inheritance122ab4aaad">
<area shape="rect" href="pyamp_patterns_interfaces_requiredProperties.html#pyamp.patterns.interfaces.requiredProperties.RequiredProperties" title="pyamp.patterns.interfaces.requiredProperties.RequiredProperties" alt="" coords="27,7,461,33"/>
<area shape="rect" href="#pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsParentBase" title="pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsParentBase" alt="" coords="5,84,483,111"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsParentBase">
<em class="property">class </em><tt class="descclassname">pyamp.patterns.interfaces.finalFunctionsMeta.</tt><tt class="descname">FinalFunctionsParentBase</tt><a class="reference internal" href="../_modules/pyamp/patterns/interfaces/finalFunctionsMeta.html#FinalFunctionsParentBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsParentBase" title="Permalink to this definition">¶</a></dt>
<dd><p>The FinalFunctionsParentBase provides a base class which provides the
ability to define final functions in the base class. This will prevent any
subclasses from overloading these specific, i.e., final, functions.</p>
<p>This class provides the ability to specify the specific metaclass that
<strong>must</strong> be defined for all subclasses of this base class. The metaclass
chosen should be a subclass of the <a class="reference internal" href="#pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsMeta" title="pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsMeta"><tt class="xref py py-class docutils literal"><span class="pre">FinalFunctionsMeta</span></tt></a> metaclass
which defines the list of final functions and keeps them from being
overridden.</p>
<p>Create the FinalFunctionsParentBase class.</p>
</dd></dl>

</div>
<div class="section" id="the-finalfunctionsmeta-class">
<h2>The FinalFunctionsMeta class<a class="headerlink" href="#the-finalfunctionsmeta-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-e098566f41358a2ae1b880a69ec7ae3edecfa6f1.png" alt="Inheritance diagram of pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsMeta" usemap="#inheritance1b704ae4d8" class="inheritance"/>
<map id="inheritance1b704ae4d8" name="inheritance1b704ae4d8">
<area shape="rect" href="#pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsMeta" title="pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsMeta" alt="" coords="5,7,440,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsMeta">
<em class="property">class </em><tt class="descclassname">pyamp.patterns.interfaces.finalFunctionsMeta.</tt><tt class="descname">FinalFunctionsMeta</tt><a class="reference internal" href="../_modules/pyamp/patterns/interfaces/finalFunctionsMeta.html#FinalFunctionsMeta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.patterns.interfaces.finalFunctionsMeta.FinalFunctionsMeta" title="Permalink to this definition">¶</a></dt>
<dd><p>The FinalFunctionMeta class is a metaclass which provides the ability
to define a list of functions that should not be allowed to be overridden
by classes which use this metaclass.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The finalFunctionsMeta module</a><ul>
<li><a class="reference internal" href="#the-requiredproperties-class">The RequiredProperties class</a></li>
<li><a class="reference internal" href="#the-finalfunctionsparentbase-class">The FinalFunctionsParentBase class</a></li>
<li><a class="reference internal" href="#the-finalfunctionsmeta-class">The FinalFunctionsMeta class</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="mod_pyamp_patterns_interfaces.html"
                        title="previous chapter">The interfaces module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="pyamp_patterns_interfaces_requiredProperties.html"
                        title="next chapter">The requiredProperties module</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/_generated/pyamp_patterns_interfaces_finalFunctionsMeta.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_patterns_interfaces_requiredProperties.html" title="The requiredProperties module"
             >next</a> |</li>
        <li class="right" >
          <a href="mod_pyamp_patterns_interfaces.html" title="The interfaces module"
             >previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_patterns.html" >The patterns module</a> &raquo;</li>
          <li><a href="mod_pyamp_patterns_interfaces.html" >The interfaces module</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>